package com.example.activity_usage.jump;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.example.activity_usage.R;

public class JumpFinishActivity extends AppCompatActivity implements View.OnClickListener{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_jump_finish);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

        ImageButton btnBack = findViewById(R.id.btn_back);
        btnBack.setOnClickListener(this);

        Button btnFinish = findViewById(R.id.btn_finish);
        btnFinish.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (R.id.btn_back == v.getId() || R.id.btn_finish == v.getId()) {
            // 结束当前activity并返回上一个activity
            finish();
        }
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.d("Activity生命周期", "onStart");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.d("Activity生命周期", "onResume");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.d("Activity生命周期", "onPause");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.d("Activity生命周期", "onStop");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.d("Activity生命周期", "onDestroy");
    }
}